﻿using System;
using Autodesk.Revit.DB;

namespace YJKRoom.NumberRoomControler
{
	internal class XYComparer
	{
		private static bool LessThan(double val1, double val2)
		{
			return val1 - val2 < -0.0001;
		}

		private static bool IsEqual(double val1, double val2)
		{
			return !XYComparer.LessThan(val1, val2) && !XYComparer.LessThan(val2, val1);
		}

		public static int Compare(XYZ pt1, XYZ pt2)
		{
			if (XYComparer.IsEqual(pt1.Y, pt2.Y))
			{
				if (XYComparer.IsEqual(pt1.X, pt2.X))
				{
					return 0;
				}
				if (XYComparer.LessThan(pt1.X, pt2.X))
				{
					return -1;
				}
			}
			else if (XYComparer.LessThan(pt1.Y, pt2.Y))
			{
				return -1;
			}
			return 1;
		}
	}
}
